package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Glossary;
import com.skyolder.milkbee.repository.GlossaryRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Glossary.
 */
@Service
@Transactional
public class GlossaryService {

    private final Logger log = LoggerFactory.getLogger(GlossaryService.class);
    
    @Inject
    private GlossaryRepository glossaryRepository;

    /**
     * Save a glossary.
     *
     * @param glossary the entity to save
     * @return the persisted entity
     */
    public Glossary save(Glossary glossary) {
        log.debug("Request to save Glossary : {}", glossary);
        Glossary result = glossaryRepository.save(glossary);
        return result;
    }

    /**
     *  Get all the glossaries.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Glossary> findAll(Pageable pageable) {
        log.debug("Request to get all Glossaries");
        Page<Glossary> result = glossaryRepository.findAll(pageable);
        return result;
    }
    @Transactional(readOnly = true) 
    public List<Glossary> loadAll() {
    	log.debug("Request to get all Glossaries");
    	List<Glossary> result = glossaryRepository.loadAll();
    	return result;
    }

    /**
     *  Get one glossary by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Glossary findOne(Long id) {
        log.debug("Request to get Glossary : {}", id);
        Glossary glossary = glossaryRepository.findOne(id);
        return glossary;
    }

    /**
     *  Delete the  glossary by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Glossary : {}", id);
        glossaryRepository.delete(id);
    }
    /**
     * 过滤敏感词
     * @param src
     * @return
     */
    public String purify(String src){
    	return src;
    }
}
